home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / utils / file / fileutil.13 / fileutil / fileutils-3.13 / lib / memcpy.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-02-11  |  585 b   |  26 lines

  1. /* memcpy.c -- copy memory.
  2.    Copy LENGTH bytes from SOURCE to DEST.  Does not null-terminate.
  3.    The source and destination regions may not overlap.
  4.    In the public domain.
  5.    By Jim Meyering.  */
  6.  
  7. /* FIXME: remove this before release.  */
  8. #include <assert.h>
  9. #ifndef ABS
  10. # define ABS(x) ((x) < 0 ? (-(x)) : (x))
  11. #endif
  12.  
  13. void
  14. memcpy (dest, source, length)
  15.      char *dest;
  16.      const char *source;
  17.      unsigned length;
  18. {
  19.   assert (length >= 0);
  20.   /* Make sure they don't overlap.  */
  21.   assert (ABS (dest - source) >= length);
  22.  
  23.   for (; length; --length)
  24.     *dest++ = *source++;
  25. }
  26.